//
//  EnterDetailTableViewCell.m
//  ToWhere
//
//  Created by dllo on 15/11/19.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "EnterDetailTableViewCell.h"
#import "EnterTableViewTwoCell.h"

@interface EnterDetailTableViewCell()

@property(nonatomic, retain) UILabel *decribeLabel;

@property(nonatomic, retain) UIButton *locationBtn;

@property(nonatomic, retain) UIImageView *image;

@property(nonatomic, retain) UILabel *label;

@end

@implementation EnterDetailTableViewCell

- (void)dealloc
{
    [_decribe release];
    [_location release];
    [_decribeLabel release];
    [_locationBtn release];
    [_image release];
    [_label release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.decribeLabel = [[UILabel alloc]init];
        self.decribeLabel.textColor = [UIColor colorWithWhite:0.322 alpha:1.000];
        self.decribeLabel.font = [UIFont systemFontOfSize:15 * kWidth];
        self.decribeLabel.numberOfLines = 0;
        [self.contentView addSubview:self.decribeLabel];
        [_decribeLabel release];
        
        self.locationBtn = [[UIButton alloc]init];
        [self.contentView addSubview:self.locationBtn];
        [_locationBtn release];
        [self.locationBtn addTarget:self action:@selector(locationAction:) forControlEvents:UIControlEventTouchUpInside];
        
        self.image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Enter_Location"]];
        [self.locationBtn addSubview:self.image];
        [_image release];
        
        self.label = [[UILabel alloc]init];
        self.label.textColor = [UIColor colorWithRed:0.149 green:0.516 blue:1.000 alpha:1.000];
        self.label.font = [UIFont systemFontOfSize:15 * kWidth];
        [self.locationBtn addSubview:self.label];
        [_label release];
    }
    return self;
}

-(void)locationAction:(UIButton *)btn
{
    NSLog(@"%@", self.label.text);
    [self.delegate sendToTravetTourDetailsViewController:self.ID];
}

-(void)setID:(NSNumber *)ID
{
    if (_ID != ID) {
        [_ID release];
        _ID = [ID retain];
    }
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat height = [EnterTableViewTwoCell heightOfLabel:self.decribeLabel.text andTextFont:[UIFont systemFontOfSize:15 * kWidth] andTextWidth:self.frame.size.width - 20 * kWidth];
    self.decribeLabel.frame = CGRectMake(10 * kWidth, 0, self.frame.size.width - 20 * kWidth, height);
    self.locationBtn.frame = CGRectMake(10 * kWidth, self.decribeLabel.frame.origin.y +  self.decribeLabel.frame.size.height , 200 * kWidth, 20 * kHeight);
    self.image.frame = CGRectMake(0, 0, 20 * kWidth, 20 * kHeight);
    self.label.frame = CGRectMake(25 * kWidth, 0, self.locationBtn.frame.size.width - 20 * kWidth, 20 * kHeight);
}

-(void)setDecribe:(NSString *)decribe
{
    if (_decribe != decribe) {
        [_decribe release];
        _decribe = [decribe copy];
    }
    self.decribeLabel.text = decribe;
}

-(void)setLocation:(NSString *)location
{
    if (_location != location) {
        [_location release];
        _location = [location copy];
    }
 self.label.text = location;
}


@end
